home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Almathera Ten Pack 2: CDPD 1
/
Almathera Ten on Ten - Disc 2: CDPD 1.iso
/
pd
/
076-100
/
081
/
icon
/
wordcnt.icn
< prev
next >
Wrap
Text File
|
1995-03-13
|
540b
|
24 lines
#
# W O R D C O U N T I N G
#
# This program tabulates the words in standard input and writes the
# results with the words in a column 20 characters wide. The definition
# of a "word" is naive.
procedure main()
wordcount(20)
end
procedure wordcount(n)
local t, line, x, y
static letters
initial letters := &lcase ++ &ucase
t := table(0)
while line := read() do
line ? while tab(upto(letters)) do
t[tab(many(letters))] +:= 1
x := sort(t)
every y := !x do write(left(y[1],n),y[2])
end